package com.frame.demo.rest;


import javax.inject.Inject;

/**
 * 用于产生retorift的Service
 * @author bingo
 * @version 1.2.0
 * @date 15/9/30
 */
public class RetrofitHelper {
    private RestClient mRestClient;

    @Inject
    public RetrofitHelper() {
        setupRestClient();
    }

    /**
     * 根据特定的条件创建不同的RestClient
     */
    private void setupRestClient() {
        if (mRestClient == null) {
            mRestClient = new RestClient();
        }
    }

    /**
     * 根据restful接口得到请求网络的实例
     *
     * @param service
     * @param <T>
     * @return
     */
    public <T> T getService(Class<T> service) {
        return mRestClient.getRestAdapter().create(service);
    }


}
